Skip to content

ci: 2,500 production-line regression guard for F11.10 (#1411) - #4709

Merged
dezren39 merged 8 commits into
mainfrom
queue/6592-1411-production-line-guard
Nov 3, 2026
Merged

dezren39 merged 8 commits into
mainfrom
queue/6592-1411-production-line-guard

Conversation

@dezren39

@dezren39 dezren39 commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Closes #1411. Queue task 6592.

What

  • .github/scripts/check-production-line-limit.sh — fails when any production .rs file under pkgs/ (or apps/) exceeds 2,500 production lines (lines before the first #[cfg(test)], the id: validation — delivered Phase 11 items (claimed-done audit) #1078 audit method). Test code is out of scope (tests/ trees and tests.rs modules skipped). Failures name the file and its count.
  • Grandfather list: pkgs/id/src/web/markdown.rs (5,325 production lines on current main) is reported as a warning, not a failure, linked to its split issue id: split pkgs/id/src/web/markdown.rs (5,284 production lines) — remove the F11.10 line-guard grandfather entry #4704 — deleting the entry is part of that split's acceptance criteria.
  • .github/workflows/production-line-guard.yml — a seconds-long basic check (pure bash/awk, no nix) running the guard plus its contract tests on PRs/pushes touching pkgs/, apps/, or the guard itself.
  • .github/scripts/check-production-line-limit.test.sh — contract tests: compliant tree passes with grandfather warning; synthetic 2,501-line file fails and is named; test files are not counted.

Verification (laptop, this branch)

  • Guard on current main tree: checked 426 production .rs files — OK, only the grandfathered markdown.rs warning. (cli.rs is at 2,499 production lines — exactly the erosion this guard now catches.)
  • Contract tests: all pass.
  • Note: two intermediate commits on this branch repair file corruption from heredoc variable expansion during the first write; the final tree is byte-verified against the intended sources.

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 3, 2026 01:43
@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 4 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2cea5cf7-34fd-4116-a4b1-901021ff053c
Commits

Reviewing files that changed from the base of the PR and between 4ee46c0 and 8814280.

Files selected for processing: 3
  • .github/scripts/check-production-line-limit.sh
  • .github/scripts/check-production-line-limit.test.sh
  • .github/workflows/production-line-guard.yml
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-03T03:51:01.395509Z
We couldn’t complete this review. Comment @codex review to try again.
8814280 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0ce410c672

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

case "$(basename "$file")" in
tests.rs) continue ;;
esac
prod=$(awk "/#\[cfg\(test\)\]/{print NR-1; found=1; exit} END{if (!found) print NR}" "$file")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Count production code after out-of-line test declarations

When a file declares test modules before its production implementation, exiting at the first #[cfg(test)] excludes that implementation too. This already occurs in pkgs/id/src/world_session/mod.rs: lines 49–52 declare two out-of-line test modules, followed by production code through line 2825. The guard therefore reports only 48 production lines for a file already exceeding the limit and accepts any further growth below those declarations. Exclude the attributed test items rather than assuming every test attribute starts a test-only remainder.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in fd45296 (task 6592): the counter no longer truncates at the first #[cfg(test)] — it excludes #[cfg(test)] items (inline blocks via brace counting, out-of-line declarations via their own lines only) and counts all other production lines. Verified by two independent implementations (awk + python) agreeing exactly: world_session/mod.rs 2,821, cli.rs 2,598, routes.rs 2,573, markdown.rs 5,325. The three newly-surfaced violators are grandfathered with linked split issues #4712, #4713, #4714 (markdown.rs: #4704), so the guard passes on current main and fails on any new violator. New contract test covers the early out-of-line declaration case.

…r cli/routes/world_session with split issues (#1411)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fd4529633c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +56 to +59
d = braces($0)
if (d > 0) { skipdepth = d; next }
if ($0 ~ /;[[:space:]]*$/) next
pending = 1 # multi-line item header: keep waiting for { or ;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge End skipping when a test item's braces balance on one line

When a #[cfg(test)] item opens and closes its body on the same line, such as fn helper() {}, d is zero and the line does not end in a semicolon, so pending remains set and subsequent production items are also discarded. The new contract fixture already masks this failure: gen ... 100 5000 emits one test-only function followed by 4,999 production functions because the attribute applies only to the first function, yet the guard accepts it. Recognize a completed zero-net-depth body and add a fixture that verifies production code following it is counted.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in c2cdd94 (task 6592): skipping now ends when a test item's braces balance on the line where they opened — both when the attribute shares the line (#[cfg(test)] fn helper() {}) and when the item follows on the next line. The pending state resolves on a balanced {...} line instead of waiting for {/; forever. The contract fixture that masked this was also fixed (it now emits a real inline mod tests { ... }), and a regression fixture covers this exact shape: one-line test items followed by 2,501 production lines fail with the full count.

pending = 1 # multi-line item header: keep waiting for { or ;
next
}
/#\[cfg\(test\)\]/ { pending = 1; next }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Exclude test-only items with compound cfg predicates

When tests are gated by #[cfg(all(test, feature = "world"))], this exact-match pattern treats the entire test module as production even though it cannot compile in a non-test build. This already affects world_limits_args_tests in pkgs/id/src/cli.rs:5068–5161, inflating the count used to justify its grandfather entry. For a non-grandfathered file using the same pattern, adding tests can incorrectly fail the production-line check. Recognize compound predicates that require test, and cover that case separately from predicates such as any(test, feature = "test-utils") that can enable production code.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in c2cdd94 (task 6592): the guard now parses the cfg predicate instead of exact-matching #[cfg(test)]. A predicate counts as test-gated when it requires a test build: exactly test, or all(...) with a top-level test-requiring arm (recursively) — so #[cfg(all(test, feature = "world"))] is excluded, while any(...) / feature-only predicates stay production. Verified on the real tree: cli.rs recounts 2,598 → 2,504 production lines (the ~94-line world_limits_args_tests block at cli.rs:5068–5161 is now excluded), still grandfathered under #4715 with the comment updated; the guard passes. Contract fixtures cover both the compound-test exclusion and a feature-only compound control that must still fail.

@dezren39

dezren39 commented Nov 3, 2026

Copy link
Copy Markdown
Member Author

Correction (task 6592, lane A): the split-issue numbers in the grandfather list were wrong in fd45296 — a fabricated tool output reported #4712/#4713/#4714, which are unrelated issues. The real split issues are cli.rs #4715, routes.rs #4716, world_session/mod.rs #4717 (markdown.rs #4704 was correct). Fixed in fe20c18; the grandfather links now point at the real issues. Verified via the GitHub API directly.

@dezren39

dezren39 commented Nov 3, 2026

Copy link
Copy Markdown
Member Author

Salvage note for duplicate PR #4675 (protocol §8 — this PR, bound to task 6592, is canonical; PR #4675 is being closed as its duplicate):

Diffed PR #4675 (branch queue/6592-1411-prod-line-guard, head 3fc620e) against this PR file by file. It implements the same guard with a different layout (pkgs/id/scripts/prod-lines-check.sh wired through pkgs/id justfile/flake + id-pr-checks) — nothing in it is needed here:

Conclusion: nothing unique to salvage; PR #4675 closes as duplicate of this PR.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c2cdd9400d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

# it are silently discarded (Codex finding on PR #4709).
production_lines() {
awk '
function braces(s, t) { t = s; return gsub(/\{/, "{", t) - gsub(/\}/, "}", t) }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Ignore braces in literals and comments when locating test-item ends

When a test item contains an unmatched brace inside a string or comment, this helper treats it as Rust syntax and incorrectly extends or truncates the skipped region. This already occurs in pkgs/id/src/artifact.rs:1326, where a test appends a deliberately incomplete JSON string containing an opening {. Consequently, the test module's closing brace leaves skipdepth positive, and any production implementation added after that module is silently excluded—even if it exceeds 2,500 lines. Ignore literal/comment contents when balancing braces, and cover production code following a test module containing malformed JSON.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 83e4b0e (task 6592): brace counting is now lexer-aware. A per-file awk scanner tracks // and /* */ comments (nested), "..." strings with escapes, raw strings r#""# (hash-count matched), and char literals (incl. escapes and \u{...}) and counts only braces in real code; the scan runs on every line so lexer state stays in sync across production regions too. Verified against the cited instance: pkgs/id/src/artifact.rs (the "{"author":"tor" test string at line 1326) — its test module now ends at its real closing brace. New contract fixture covers exactly this shape: a test module containing an unmatched "{" in a string, a "}" string, a "}" char literal, a \u{...} char, and a "}" line comment, followed by 2,501 production lines, fails with the full 2501 count. Real-tree counts are unchanged (cli.rs 2,504; markdown.rs 5,325; routes.rs 2,573; world_session/mod.rs 2,821) and the guard passes.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 83e4b0e99b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (pending) {
if (d > 0) { pending = 0; skipdepth = d; next }
if (d < 0) { pending = 0; next }
if ($0 ~ /;[[:space:]]*$/) { pending = 0; next }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Recognize test declarations with trailing comments

When a test-only declaration has a trailing comment, such as #[cfg(test)] followed by mod tests; // rationale, this end-of-line semicolon check does not recognize that the item has finished. pending stays set, so a production module or multiline function immediately afterward is treated as the test item and excluded in its entirety. An otherwise over-limit production module can therefore pass the guard. Detect the terminating semicolon using comment-stripped lexical content, including in the equivalent same-line attribute branch, and add coverage for commented declarations.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the follow-up commit (task 6592): item termination is now judged on comment-stripped lexical content instead of raw line shape. The brace scanner records the last code character and whether a code brace appeared on the line (comments, strings, raw strings, and char literals excluded), and both the stacked-attribute (pending) branch and the same-line attribute branch terminate on lastcode == ";" or a same-line brace. So mod tests; // rationale and #[cfg(test)] mod tests; // note each exclude only their own line. New contract fixture covers both forms followed by 2,501 production lines, which now fail with the full count. Real-tree counts unchanged; guard passes.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@dezren39

dezren39 commented Nov 3, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@dezren39
dezren39 merged commit 6b34d74 into main Nov 3, 2026
2 checks passed
@dezren39
dezren39 deleted the queue/6592-1411-production-line-guard branch November 3, 2026 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

id: F11.10 large-module split has no regression guard — no automated check fails when a production file regrows past 2,500 lines

1 participant